package com.zeldu.uaa.controller;

import com.zeldu.common.model.response.CommonCode;
import com.zeldu.common.model.response.ResponseResult;
import com.zeldu.uaa.service.SignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SignInController {
    @Autowired
    SignService signService;
    @PostMapping("/sign")
    public ResponseResult SignIn(@RequestParam("email") String email,@RequestParam("username") String userName,
                                 @RequestParam("password") String password,
                                 @RequestParam("code")String code,@RequestParam("realname")String realName,@RequestParam("identity") String identity){
   return signService.SignIn(email,userName,password,code,realName,identity);

    }

    @PostMapping("/change")
    @PreAuthorize("hasAnyAuthority('stu','tea')")
    public ResponseResult ChangePWD(String oldPwd,String newPwd,String identity){
     return    signService.ChangePwd(oldPwd,newPwd,identity);

    }


    @PostMapping("/findback")
    public ResponseResult findPwdBack(@RequestParam("code") String code,@RequestParam("newPwd") String newPwd,
                                      @RequestParam("email") String email,@RequestParam("identity") String identity){
       return      signService.findPwdBack(code,newPwd,email,identity);
    }

}
